< previous page page_570 next page >

Page 570
e10a6a0a59f035e870d90cca05b85fce.gif
Dim new_rmin As Single
Dim new_rmax As Single

    Rmin = 1E+30
    Rmax = -1E+30

    For Each solid In Solids
        solid.GetRminRmax new_rmin, new_rmax, _
            light.X, light.Y, light.Z
        If Rmin > new_rmin Then Rmin = new_rmin
        If Rmax < new_rmax Then Rmax = new_rmax
    Next solid

    light.Rmin = Rmin
    light.Kdist = Rmax - 2 * Rmin
End Sub
Example program Light3, shown in Figure 16.5, is similar to program Light2 except it adds the distance term to the shading model. Use the option buttons to select a scene. Use the check boxes to determine which light sources are used. Compare Figures 16.4 and 16.5 to see how the distance term works.
You may want to experiment with different formulas for setting kdist. For example, setting kdist to the following value makes the darkest polygons much darker.
e10a6a0a59f035e870d90cca05b85fce.gif
kdist =(rmax - 5 * rmin) / 4
Because only the few polygons closest to the light source keep their original intensities, the scene as a whole is darker.
Specular Reflection
Most objects do not have perfectly dull, matte surfaces. Most surfaces have some degree of reflectiveness. When you view a surface at a certain angle, much of the incident light that strikes the surface is reflected toward your eyes. This is called specular reflection.
For example, when you look at a red billiard ball under a bright white light, you see a bright highlight on the ball. The highlight is due to specular reflection. The light that reaches your eyes after striking other parts of the ball is due to diffuse reflection and ambient light.
If you look closely at the highlight, you will see it is much whiter than the rest of the ball. In the highlight, the ball reflects most of the white light that hits it. Other parts of the ball reflect mostly red light, so they appear redder.
A mirror is an almost perfectly reflective surface. Light that strikes a mirror making angle q with the surface normal reflects off the mirror, making another angle q with the normal as shown in Figure 16.6.

 
< previous page page_570 next page >